<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*, util.*"%>
<%
	ChecklistItemModel obj;
	Object temp = request.getAttribute("checklistItem");
	if (temp != null) {
		try {
			obj = (ChecklistItemModel) temp;
		} catch (Exception ex) {
			obj = new ChecklistItemModel();
		}
	} else {
		obj = new ChecklistItemModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Checklist Item</title>

<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" />

<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery-1.6.1.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>

<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>

<link rel="stylesheet" href="css/inputForm.css" />

<script language="javascript" type="text/javascript">
	var requiredInputs = [['display_index','display_index_required'],['name','name_required'],['remark','remark_required'],['id_employee','id_employee_required'],['id_company','id_company_required'],['start_time','start_time_date_required', 'start_time','start_time_time_required'],['end_time','end_time_date_required', 'end_time','end_time_time_required'],['status','status_required'],['index','index_required'],['type','type_required'],['notification','notification_required'],['id_parent','id_parent_required']];
	var intInputs = [['id_checklist','id_checklist_invalid'],['id_employee','id_employee_invalid'],['id_company','id_company_invalid'],['status','status_invalid'],['index','index_invalid'],['type','type_invalid'],['notification','notification_invalid'],['id_parent','id_parent_invalid']];
	var doubleInputs = [];
	var dateInputs = [['start_time','start_time_date_invalid'],['end_time','end_time_date_invalid']];
	var timeInputs = [['start_time','start_time_time_invalid'],['end_time','end_time_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
     <jsp:include page="menu.jsp"></jsp:include>
	<br />
    <table>
		<tr>
			<td>
	            <form action="checklistItem?mode=insert" method="post"
                    onSubmit="return checkInputs()"
                    onreset="return confirm('Do you really want to reset the form?')">
		            <table class="tblInput" border="1">
			            <tr class="inputHeader">
				            <th colspan="3" class="inputHeader">Create New Checklist Item</th>
			            </tr>
            			<tr class="trField">
				<td class="tdFieldName">Id Checklist</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_checklist" name="id_checklist" maxlength="10" value="<%=obj.getIdChecklistToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_checklist_required" class="errMsg" style="display: none;">Id Checklist is required</span> 
					<span id="id_checklist_invalid" class="errMsg" style="display: none;">Id Checklist is invalid</span>
                    <span id="id_checklist_error" class="errMsg"><%=obj.errMsgs.IdChecklist%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Display Index</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="display_index" name="display_index" maxlength="10" value="<%=obj.getDisplayIndexToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="display_index_required" class="errMsg" style="display: none;">Display Index is required</span>
					<span id="display_index_invalid" class="errMsg" style="display: none;">Display Index is invalid</span>
                    <span id="display_index_error" class="errMsg"><%=obj.errMsgs.DisplayIndex%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getNameToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="name_required" class="errMsg" style="display: none;">Name is required</span>
					<span id="name_invalid" class="errMsg" style="display: none;">Name is invalid</span>
                    <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Remark</td>				    <td class="tdFieldInput">
					<textarea id="remark" name="remark" rows="5" class="inputTextarea"><%=obj.getRemarkToString()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="remark_required" class="errMsg" style="display: none;">Remark is required</span>
					<span id="remark_invalid" class="errMsg" style="display: none;">Remark is invalid</span>
                    <span id="remark_error" class="errMsg"><%=obj.errMsgs.Remark%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Group</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_group" name="ckb_is_group"
								onchange="toggleControls(['is_group_true', 'is_group_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_group_true" name="is_group" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_group_false" name="is_group" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Employee</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_employee" name="id_employee" maxlength="10" value="<%=obj.getIdEmployeeToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_employee_required" class="errMsg" style="display: none;">Id Employee is required</span> 
					<span id="id_employee_invalid" class="errMsg" style="display: none;">Id Employee is invalid</span>
                    <span id="id_employee_error" class="errMsg"><%=obj.errMsgs.IdEmployee%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Company</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_company" name="id_company" maxlength="10" value="<%=obj.getIdCompanyToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_company_required" class="errMsg" style="display: none;">Id Company is required</span> 
					<span id="id_company_invalid" class="errMsg" style="display: none;">Id Company is invalid</span>
                    <span id="id_company_error" class="errMsg"><%=obj.errMsgs.IdCompany%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Start Time</td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="start_time_date" name="start_time_date" value="<%=StringUtil.toDateTimeString(obj.getStartTime())%>" />
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('start_time_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="start_time_time" name="start_time_time" value="<%=obj.getStartTime()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="start_time_error" class="errMsg"><%=obj.errMsgs.StartTime%></span>
					<div class="divErr">
						<span id="start_time_date_required" class="errMsg"
							style="display: none;">Start Time's date is required</span>
					</div>
					<div class="divErr">
						<span id="start_time_time_required" class="errMsg"
							style="display: none;">Start Time's time is required</span>
					</div>
					<div class="divErr">
						<span id="start_time_date_invalid" class="errMsg"
							style="display: none;">Start Time's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="start_time_time_invalid" class="errMsg"
							style="display: none;">Start Time's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">End Time</td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="end_time_date" name="end_time_date" value="<%=StringUtil.toDateTimeString(obj.getEndTime())%>" />
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('end_time_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="end_time_time" name="end_time_time" value="<%=obj.getEndTime()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="end_time_error" class="errMsg"><%=obj.errMsgs.EndTime%></span>
					<div class="divErr">
						<span id="end_time_date_required" class="errMsg"
							style="display: none;">End Time's date is required</span>
					</div>
					<div class="divErr">
						<span id="end_time_time_required" class="errMsg"
							style="display: none;">End Time's time is required</span>
					</div>
					<div class="divErr">
						<span id="end_time_date_invalid" class="errMsg"
							style="display: none;">End Time's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="end_time_time_invalid" class="errMsg"
							style="display: none;">End Time's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="status" name="status" maxlength="10" value="<%=obj.getStatusToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span>
                    <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Index</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="index" name="index" maxlength="10" value="<%=obj.getIndexToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="index_required" class="errMsg" style="display: none;">Index is required</span> 
					<span id="index_invalid" class="errMsg" style="display: none;">Index is invalid</span>
                    <span id="index_error" class="errMsg"><%=obj.errMsgs.Index%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Type</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="type" name="type" maxlength="10" value="<%=obj.getTypeToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="type_required" class="errMsg" style="display: none;">Type is required</span> 
					<span id="type_invalid" class="errMsg" style="display: none;">Type is invalid</span>
                    <span id="type_error" class="errMsg"><%=obj.errMsgs.Type%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Draft</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_draft" name="ckb_is_draft"
								onchange="toggleControls(['is_draft_true', 'is_draft_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_draft_true" name="is_draft" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_draft_false" name="is_draft" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Notification</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" value="<%=obj.getNotificationToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="notification_required" class="errMsg" style="display: none;">Notification is required</span> 
					<span id="notification_invalid" class="errMsg" style="display: none;">Notification is invalid</span>
                    <span id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Parent</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_parent" name="id_parent" maxlength="10" value="<%=obj.getIdParentToString()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_parent_required" class="errMsg" style="display: none;">Id Parent is required</span> 
					<span id="id_parent_invalid" class="errMsg" style="display: none;">Id Parent is invalid</span>
                    <span id="id_parent_error" class="errMsg"><%=obj.errMsgs.IdParent%></span>
                </td></tr>
			
			            <tr class="trInputBottom">
				            <td class="tdInputBottom" colspan="3">
					            <table class="tblSubmit" align="center">
						            <tr class="trSubmit">
							            <td class="tdSubmit"><input type="submit" value="Submit" />
							            </td>
							            <td class="tdReset"><input type="reset" value="Reset" /></td>
						            </tr>
					            </table></td>
			            </tr>
		            </table>
	            </form>
            </td>
		</tr>
	</table>
    <br />
	<jsp:include page="checklistItemList.jsp?embedded=true"></jsp:include>
</body>
</html>